fError = 1e-6
iDenominator = 1
bAdd = True
fPi = 0.0
fItem = 1.0 / iDenominator
while fItem >= fError:
    fPi = fPi + (fItem if bAdd else -fItem)
    iDenominator += 2
    fItem = 1 / iDenominator 
    bAdd = False if bAdd else True 
fPi = fPi * 4
print(f"pi = {fPi:.15}")
